<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">

    <title>登录页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/login.css}">

</head>
<body>

<div class="login-main">
    <header class="layui-elip">登录</header>
    <div th:if="${param.error}" th:text="账号错误" style="color: red"></div>
    <form class="layui-form" method="post" action="/login">
        <div class="layui-input-inline">
            <input type="text" name="username" required lay-verify="required" placeholder="用户名" autocomplete="off"
                   class="layui-input">
            <input type="hidden" name="password" value="123123"/>
            <input type="hidden" name="rememberMe" value="true"/>
        </div>
        <div class="layui-input-inline login-btn">
            <button lay-submit lay-filter="login" class="layui-btn">登录</button>
        </div>
        <hr/>
        <p><a th:href="@{/register}" class="fl">立即注册</a></p>
    </form>
</div>

<script th:inline="javascript">var ctx = [[@{/}]];</script>
<script th:src="@{/layui/layui.js}"></script>
<script th:src="@{/js/js-cookie.js}"></script>
<script th:src="@{/js/axios.js}"></script>
<script th:src="@{/js/axios_instance.js}"></script>
<script type="text/javascript">
    layui.use(['form','layer','jquery'], function () {

        // 操作对象
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(login)',function (data) {
            // console.log(data.field);
            // request({
            //     method: 'post',
            //     url: '/login',
            //     data: data.field,
            // }).then(res => {
            //     if (res.code == 0){
            //         Cookies.set('layim_access_token',res.data.token.access_token,{ expires: 365 });
            //         location.href = location.origin + '/index'
            //     }else{
            //         layer.msg(res.msg)
            //     }
            // })
            // return false;
        })

    });
</script>
</body>
</html>